package easy;

public class Solution_476 {
    public int findComplement(int num) {
        int sub = 0;
        for (int i = 1;num!=0; i = i << 1) {
            sub += ((num-1) % 2) * i ;
            num = num >> 1;
        }
        return sub;
    }

    public static void main(String[] args) {
        Solution_476 model = new Solution_476();
        System.out.println(model.findComplement(1));
        System.out.println(model.findComplement(5));
        System.out.println(model.findComplement(7));
        System.out.println(model.findComplement(6));
        System.out.println(model.findComplement(2147483647));
    }
}
